#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifndef TYPE_H
#define TYPE_H

typedef struct node node;
typedef struct variable variable;
typedef struct instruction instruction;
typedef struct function function;
typedef struct param param;
typedef enum toutLesTypes unType;

enum toutLesTypes{PARAMETRE, INTEG, STR, FLOA, BOOL, VOID, FONCTION, UNDEF, UINTEG};

struct variable{
  char* nom;
  int* probType;//0 = undef, 1=int, 2=string, 3=float, 4=boolean, void=5
  unType type;
};

struct function{
  char* nom;
  node* parametres;
  variable* retour;
};

struct instruction{
  char* fonction;
  node* parametres;
  variable* retour;//la variable retournée
  instruction* next;
};

struct node{
  struct node* nSuiv;
  union {
    variable* v;
    function* f;
  };
};

node* creerNode(node* nSuiv, char* nomVar, unType type);
variable* empty_var();
void deleteInstr(instruction* i);
instruction* empty_instr();
node* chercheNode(char* nom, node* liste);
int operation(char* op, variable* a, variable* b, variable* retour);
void generiqueOp(char* op, variable* a, variable* b, variable* retour);
void ecrireFonction();
int existUndef(node* liste);
void affectType();
void affectTypeRecurs(node* parametre);

#endif
